package xyz.ddlnt.serviceusr.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import xyz.ddlnt.commonutil.result.Result;
import xyz.ddlnt.model.dto.PageDTO;
import xyz.ddlnt.model.dto.PostFavRecordDTO;
import xyz.ddlnt.model.dto.UserContentInteractionDTO;
import xyz.ddlnt.model.vo.PostRecordVO;
import xyz.ddlnt.serviceusr.service.PostFavRecordService;

import java.util.List;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/25 16:54
 */
@Slf4j
@RequestMapping("/post_fav_record")
@RestController
public class PostFavRecordController {
    @Resource
    private PostFavRecordService postFavRecordService;
    /**
     * 判断用户是否收藏了帖子
     * @param userContentInteractionDTO
     * @return
     */
    @PostMapping("/isFavorite")
    public Result<Boolean> isFavorite(@RequestBody UserContentInteractionDTO userContentInteractionDTO) {
        return Result.success(postFavRecordService.isFavorite(userContentInteractionDTO));
    }

    /**
     * 添加收藏
     * @param postFavRecordDTO
     * @return
     */
    @PostMapping("/addFav")
    public Result<Boolean> addFav(@RequestBody PostFavRecordDTO postFavRecordDTO) {
        return Result.success(postFavRecordService.addFav(postFavRecordDTO));
    }

    /**
     * 取消收藏
     * @param userContentInteractionDTO
     * @return
     */
    @PostMapping("/removeFav")
    public Result<Boolean> removeFav(@RequestBody UserContentInteractionDTO userContentInteractionDTO) {
        return Result.success(postFavRecordService.removeFav(userContentInteractionDTO));
    }

    /**
     * 获取收藏列表
     * @param pageDTO
     * @return
     */
    @PostMapping("/getFavList")
    public Result<List<PostRecordVO>> getFavList(@RequestBody PageDTO pageDTO) {
        return Result.success(postFavRecordService.getFavList(pageDTO));
    }

}
